cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(helloMPI VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(MPI REQUIRED)

if(MPI_FOUND)
    message(STATUS "Successfully found MPI:")
    message(STATUS "  MPI Version: ${MPI_VERSION}")
    if(MPI_CXX_FOUND)
        message(STATUS "  C++ MPI Compiler: ${MPI_CXX_COMPILER}")
        message(STATUS "  C++ MPI Includes: ${MPI_CXX_INCLUDE_PATH}")
        message(STATUS "  C++ MPI Libraries: ${MPI_CXX_LIBRARIES}")
    else()
        message(WARNING "C++ MPI support not found, but general MPI was found. This might indicate an issue if you plan to use C++.")
    endif()
    if(MPI_EXECUTABLE)
        message(STATUS "  MPI Launcher: ${MPI_EXECUTABLE}")
    endif()
else()
    message(FATAL_ERROR "MPI support not found. Please ensure an MPI implementation is installed and configured.")
endif()

add_executable(helloMPI helloMPI.cpp)

target_link_libraries(helloMPI PUBLIC MPI::MPI_CXX)